package mvc1;

import java.util.ArrayList;
import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class JSTLTestController {

    ArrayList<UserData> list;

    public JSTLTestController() {
        list = new ArrayList<UserData>();
        list.add(new UserData("홍길동", 18));
        list.add(new UserData("전우치", 23));
        list.add(new UserData("임꺽정", 31));
        list.add(new UserData("전봉준", 38));
    }

    @RequestMapping("jstl/test1.do")
    public String test1(Model model) {
        model.addAttribute("year", 2015);
        model.addAttribute("month", "January");
        model.addAttribute("user1", new UserData("홍길동", 18));
        model.addAttribute("tag", "<font style='color: red'>태그출력</font>");
        model.addAttribute("script", "<script>alert('안녕!');</script>");
        return "jstl/test1";
    }

    @RequestMapping("jstl/test2.do")
    public String test2(Model model) {
        model.addAttribute("user1", new UserData("홍길동", 18));
        return "jstl/test2";
    }

    @RequestMapping("jstl/test3.do")
    public String test3(Model model) {
        model.addAttribute("list", list);
        return "jstl/test3";
    }

    @RequestMapping("jstl/test4.do")
    public String test4(Model model) {
        return "jstl/test4";
    }

    @RequestMapping("jstl/test5.do")
    public String test5(Model model) {
        model.addAttribute("number1", 12345.678);
        model.addAttribute("number2", 0.5678);
        model.addAttribute("date1", new Date());
        return "jstl/test5";
    }

}
